import { View } from "../../mvc/core/View";
import { ILayer } from "../../mvc/interfaces/ILayer";
import { Global } from "../../../com/gengine/global/Global";
import { IView } from "../../mvc/interfaces/IView";
type int = number;
//class UILayer
    
    export  class UILayer extends View implements ILayer
    {
        constructor()
        {
            super();
            tabChildren = false;
            mouseEnabled = false;
            return;
        }

        public addPopUp(arg1: Object /* flash.display.DisplayObject */, arg2: Boolean=false): void
        {
            if (arg1 && this.contains(arg1) == false) 
            {
                this.addChild(arg1);
            }
            return;
        }

        public centerPopup(arg1: Object /* flash.display.DisplayObject */): void
        {
            arg1.x = (Global.stage.stageWidth - arg1.width) / 2;
            arg1.y = (Global.stage.stageHeight - arg1.height) / 2;
            return;
        }

        public setPosition(arg1: Object /* flash.display.DisplayObject */, arg2: int, arg3: int): void
        {
            arg1.x = arg2;
            arg1.y = arg3;
            return;
        }

        public isTop(arg1: Object /* flash.display.DisplayObject */): Boolean
        {
            if (this.contains(arg1)) 
            {
                return this.getChildIndex(arg1) == (this.numChildren - 1);
            }
            return false;
        }

        public removePopup(arg1: Object /* flash.display.DisplayObject */, arg2: Boolean=true): void
        {
            if (this.contains(arg1)) 
            {
                this.removeChild(arg1);
            }
            return;
        }

        public isPopup(arg1: Object /* flash.display.DisplayObject */): Boolean
        {
            return this.contains(arg1);
        }

        public setTop(arg1: Object /* flash.display.DisplayObject */): void
        {
            if (this.contains(arg1)) 
            {
                if (this.getChildIndex(arg1) != (this.numChildren - 1)) 
                {
                    this.setChildIndex(arg1, (this.numChildren - 1));
                }
            }
            return;
        }

        public resize(arg1: number, arg2: number): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < numChildren) 
            {
                loc1 = this.getChildAt(loc2);
                if (typeof loc1 === "iview") 
                {
                    loc1.x = loc1.x * arg1;
                    loc1.y = loc1.y * arg2;
                }
                ++loc2;
            }
            return;
        }
    }
